1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module shumate.MemoryCache; 26 27 private import gdk.Texture; 28 private import glib.ConstructionException; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import shumate.Tile; 32 private import shumate.c.functions; 33 public import shumate.c.types; 34 35 36 /** 37 * A cache that stores and retrieves tiles from the memory. The cache contents 38 * is not preserved between application restarts so this cache serves mostly as 39 * a quick access temporary cache to the most recently used tiles. 40 */ 41 public class MemoryCache : ObjectG 42 { 43 /** the main Gtk struct */ 44 protected ShumateMemoryCache* shumateMemoryCache; 45 46 /** Get the main Gtk struct */ 47 public ShumateMemoryCache* getMemoryCacheStruct(bool transferOwnership = false) 48 { 49 if (transferOwnership) 50 ownedRef = false; 51 return shumateMemoryCache; 52 } 53 54 /** the main Gtk struct as a void* */ 55 protected override void* getStruct() 56 { 57 return cast(void*)shumateMemoryCache; 58 } 59 60 /** 61 * Sets our main struct and passes it to the parent class. 62 */ 63 public this (ShumateMemoryCache* shumateMemoryCache, bool ownedRef = false) 64 { 65 this.shumateMemoryCache = shumateMemoryCache; 66 super(cast(GObject*)shumateMemoryCache, ownedRef); 67 } 68 69 70 /** */ 71 public static GType getType() 72 { 73 return shumate_memory_cache_get_type(); 74 } 75 76 /** 77 * Constructor of #ShumateMemoryCache. 78 * 79 * Params: 80 * sizeLimit = maximum number of tiles stored in the cache 81 * 82 * Returns: a constructed #ShumateMemoryCache 83 * 84 * Throws: ConstructionException GTK+ fails to create the object. 85 */ 86 public this(uint sizeLimit) 87 { 88 auto __p = shumate_memory_cache_new_full(sizeLimit); 89 90 if(__p is null) 91 { 92 throw new ConstructionException("null returned by new_full"); 93 } 94 95 this(cast(ShumateMemoryCache*) __p, true); 96 } 97 98 /** 99 * Cleans the contents of the cache. 100 */ 101 public void clean() 102 { 103 shumate_memory_cache_clean(shumateMemoryCache); 104 } 105 106 /** 107 * Gets the maximum number of tiles stored in the cache. 108 * 109 * Returns: maximum number of stored tiles 110 */ 111 public uint getSizeLimit() 112 { 113 return shumate_memory_cache_get_size_limit(shumateMemoryCache); 114 } 115 116 /** 117 * Sets the maximum number of tiles stored in the cache. 118 * 119 * Params: 120 * sizeLimit = maximum number of tiles stored in the cache 121 */ 122 public void setSizeLimit(uint sizeLimit) 123 { 124 shumate_memory_cache_set_size_limit(shumateMemoryCache, sizeLimit); 125 } 126 127 /** */ 128 public void storeTexture(Tile tile, Texture texture, string sourceId) 129 { 130 shumate_memory_cache_store_texture(shumateMemoryCache, (tile is null) ? null : tile.getTileStruct(), (texture is null) ? null : texture.getTextureStruct(), Str.toStringz(sourceId)); 131 } 132 133 /** */ 134 public bool tryFillTile(Tile tile, string sourceId) 135 { 136 return shumate_memory_cache_try_fill_tile(shumateMemoryCache, (tile is null) ? null : tile.getTileStruct(), Str.toStringz(sourceId)) != 0; 137 } 138 }